package com.fyl.datasource.provider;

import com.fyl.datasource.config.DataSourceProperty;
import com.fyl.datasource.spring.boot.autoconfigure.DynamicDataSourceProperties;

import java.util.Map;

public class DynamicDataSourceProvider extends AbstractDataSourceProvider {

    /**
     * 多数据源参数
     */
    private DynamicDataSourceProperties properties;

    public DynamicDataSourceProvider(DynamicDataSourceProperties properties) {
        this.properties = properties;
    }

    @Override
    public Map<Object, Object> loadDataSources() {
        Map<String, DataSourceProperty> dataSourcePropertiesMap = properties.getDatasource();
        return createDataSourceMap(dataSourcePropertiesMap);
    }

//    @Override
//    public void afterPropertiesSet() throws Exception {
//        DynamicDataSourceCreator dataSourceCreator = new DynamicDataSourceCreator();
//        dataSourceCreator.setDruidGlobalConfig(properties.getDruid());
//        dataSourceCreator.setHikariGlobalConfig(properties.getHikari());
//        super.setDataSourceCreator(dataSourceCreator);
//    }
}
